package com.wn.icloud.provider.uac.service.app;

import com.wn.icloud.biz.BaseBiz;
import com.wn.icloud.provider.uac.entity.Cover;
import com.wn.icloud.provider.uac.mapper.CoverMapper;
import com.wn.icloud.provider.uac.vo.app.AppCoverPicture;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.*;

@Service
@Transactional(rollbackFor = Exception.class)
public class AppCoverBiz  extends BaseBiz<CoverMapper, Cover> {
    /**
     * 获取最新封面管理
     */
    public Set<AppCoverPicture> getCoverToApp(){
        Set<AppCoverPicture> list = new HashSet<>();
        Example example = new Example(Cover.class);
        example.createCriteria().andEqualTo("status", 0);
        example.setOrderByClause("order_num asc,publish_time desc");
        List<Cover> covers = mapper.selectByExample(example);
        for (Cover cover : covers) {
            AppCoverPicture appCoverPicture = new AppCoverPicture();
            appCoverPicture.setId(cover.getId());
            appCoverPicture.setFilePath("http://114.116.121.16:9000/api/uac/content/cover/previewImage?filePath="+cover.getPicture());
            list.add(appCoverPicture);
        }
        return list;
    }
}
